//
//  LWPopupAnimationContainer.swift
//  LWPopupViewController-Swift
//
//  Created by 钟志远 on 2021/1/6.
//

import Foundation
import UIKit

public typealias LWAnimationBlock = (LWPopupViewController, ((Bool) -> Void)?) -> Void

@MainActor
open class LWPopupAnimationContainer {
    
    public var showAnimation: LWAnimationBlock?
    public var hiddenAnimation: LWAnimationBlock?
    
   public init() {
       setup()
    }
    
    func setup() {
        showAnimation = { pop , completeBlock in
            pop.view.alpha = 0
            UIView.animate(withDuration: 0.3) {[unowned pop] in
                pop.view.alpha = 1
            } completion: { (b) in
               completeBlock?(b)
            }
        }
        
        hiddenAnimation = { pop , completeBlock in
            UIView.animate(withDuration: 0.3) {
                pop.view.alpha = 0
            } completion: { (b) in
               completeBlock?(b)
            }
        }
    }
}
